﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

using Framework.GameStateManagment.Menue;

namespace Framework.GameStateManagment.GameScreens
{
    class MainMenue : GameScreen
    {
        MenueControl _Menue;
        Texture2D Hintergrund;
        private bool _EndGame;

        public bool EmdGame
        {
            get { return _EndGame; }
            set { _EndGame = value; }
        }

        public override void LoadContent(ContentManager Content)
        {
            #region Menue

            _Menue = new MenueControl();
            SpriteFont Font1, Font2;
            Font1 = Content.Load<SpriteFont>(@"Font\Font1");
            Font2 = Content.Load<SpriteFont>(@"Font\Font2");
            _Menue = new MenueControl("Mainmenue", new Vector2(200, 200));

            Button btnTemp = new Button();
            btnTemp.Schriftart = Font1;
            btnTemp.Texture = Content.Load<Texture2D>(@"GameScreen\Menue\Button"); // Ändern !!
            btnTemp.TextureAktiv = Content.Load<Texture2D>(@"GameScreen\Menue\Button-Highlight"); // Ändern !!

            _Menue.Schriftart = Font2;

            btnTemp.Text = "Singleplayer";
            btnTemp.Position = new Vector2(200, 300);
            btnTemp.SchriftPosition = new Vector2(btnTemp.Position.X + 50, btnTemp.Position.Y + 15);
            _Menue.AddButton(btnTemp, 0);
            //btnTemp.Text = "Multiplayer";
            //btnTemp.Position = new Vector2(200, 400);
            //btnTemp.SchriftPosition = new Vector2(btnTemp.Position.X + 50, btnTemp.Position.Y + 15);
            //_Menue.AddButton(btnTemp, 1);
            btnTemp.Text = "Optionen";
            btnTemp.Position = new Vector2(200, 400);
            btnTemp.SchriftPosition = new Vector2(btnTemp.Position.X + 50, btnTemp.Position.Y + 15);
            _Menue.AddButton(btnTemp, 1);
            btnTemp.Text = "Beenden";
            btnTemp.Position = new Vector2(200, 500);
            btnTemp.SchriftPosition = new Vector2(btnTemp.Position.X + 50, btnTemp.Position.Y + 15);
            _Menue.AddButton(btnTemp, 2);
            _Menue.TitelPosition = new Vector2(200, 200);

            #endregion

            Hintergrund = Content.Load<Texture2D>(@"GameScreen\LoadingScreenBeginn\Hintergrund");

            base.LoadContent(Content);
        }

        public override void Update()
        {
            base.Update();

            if (_Menue.IstButtonAktiv(0) && Input.MS.LeftButton == ButtonState.Pressed)
            {
                GameStateManagment.GameState = 2;
                Mouse.SetPosition(512 + 50, 362 - 50);
            }
            if (_Menue.IstButtonAktiv(1) && Input.MS.LeftButton == ButtonState.Pressed)
            {
                // Optionen
            }
            if (_Menue.IstButtonAktiv(2) && Input.MS.LeftButton == ButtonState.Pressed)
            {
                _EndGame = true;
                GameStateManagment.EndGame = true;
            }
        }

        public override void Draw()
        {
            GameStateManagment.SpriteBatch.Begin();
            // Zeichne den Hintergrund hier !
            GameStateManagment.SpriteBatch.End();

            _Menue.Draw(GameStateManagment.SpriteBatch);

            base.Draw();
        }
    }
}